import {IP} from "./requestUrl.js"

// 网络请求
export function request(ars, isShow=true) {
	isShow && uni.showLoading({
		title: '加载中'
	})
	return new Promise((resolve, reject) => {
		uni.request({
			...ars,
			url: IP + ars.url,
			success: (res) => {
				uni.hideLoading()
				resolve(res.data)
			},
			fail: (err) => {
				uni.hideLoading()
				isShow && uni.showToast({
					title: '加载失败',
					icon: 'none'
				});
				reject(err)
			}
		})
	})
}